
package com.putao.album.child;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.putao.album.R;
import com.putao.album.base.PtBaseAdapter;
import com.putao.album.child.bean.RelationItem;

import java.util.List;

/**
 * Created by chen on 15-5-5.
 */
public class ActivityChildSelectRelationAdapter extends PtBaseAdapter
{
    public ActivityChildSelectRelationAdapter(Context context, List<RelationItem> datalist)
    {
        super(context, datalist);
    }

    @Override
    public View getView(int position , View convertView , ViewGroup parent)
    {
        ViewHolder viewHolder;
        if (convertView == null)
        {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.activity_child_select_relation_item, null);
            viewHolder = new ViewHolder();
            viewHolder.icom = (ImageView) convertView.findViewById(R.id.icom);
            viewHolder.name = (TextView) convertView.findViewById(R.id.name);
            convertView.setTag(viewHolder);
        }
        else
        {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        RelationItem item = (RelationItem) getItem(position);
        viewHolder.icom.setImageResource(RelationItem.Tag.getResIdByTag(item.getTag()));
        viewHolder.name.setText(item.getName());
        return convertView;
    }

    class ViewHolder
    {
        public ImageView icom;
        public TextView name;
    }
}
